import hashlib

from django.shortcuts import redirect


def encrypt(password):
    md5 =hashlib.md5()
    md5.update(password.encode())
    result = md5.hexdigest()
    return result



def seller_decorator(func):

    def inner(request,*args,**kwargs):
        username = request.session.get('username')
        id = request.session.get('id')
        nickname = request.session.get('nickname')
        if username and nickname and id:
            return func(request,*args,**kwargs)
        else:
            return redirect('/Seller/login')
    return inner